package com.buba.controller;

/**
 * 话题列表
 * LC: 2023-02-20 20:01
 */

import com.buba.service.FileService;
import com.buba.service.TopicService;
import entity.HistoryRecordEntiry;
import org.apache.ibatis.annotations.Update;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import result.CommonResult;

@RestController
@CrossOrigin
public class TopicController {

    @Autowired
    private TopicService topicService;

    /**
     * 话题增加浏览数
     * @param id
     * @return
     */
    @PutMapping("/updateTopicLabel")
    public CommonResult updateTopicLabel( Integer id){
        return CommonResult.ok(topicService.updetTopicLabel(id));
    }
    /**
     * 查询话题列表
     * @return
     */
    @GetMapping("/getTopicLabel")
    public CommonResult getTopicLabel(int id){
        return CommonResult.ok(topicService.getTopicLabel(null,id));
    }

    /**
     * 查询id话题列表总数
     * @return
     */
    @GetMapping("/getTopicLabelByIdNum")
    public CommonResult getTopicLabelByIdNum(Integer id){
        return CommonResult.ok(topicService.getTopicLabelByIdNum(id));
    }

    /**
     * 查询id话题列表
     * @return
     */
    @GetMapping("/getTopicLabelById")
    public CommonResult getTopicLabelById(Integer id){
        return CommonResult.ok(topicService.getTopicLabelById(id));
    }
    /**
     * 根据id话题列表详情
     * @return
     */
    @GetMapping("/getTopicLabelByIdOne")
    public CommonResult getTopicLabelByIdOne(Integer id){
        return CommonResult.ok(topicService.getTopicLabelByIdOne(id));
    }

    /**
     * @param id 用户id
     * @param sort 排序关键字
     * @return result.CommonResult
     * @author kdj
     * @describe:查询话题推荐/最热/最新
     * @date 2023/3/8 19:24
     */
    @GetMapping("/getTopicIndexList")
    public CommonResult getTopicIndexList(Integer id,String sort){
        return CommonResult.ok(topicService.getTopicIndexList(id,sort));
    }
    /**
     * 新增历史记录
     * @return
     */
    @PostMapping("/saveHistoryRecord")
    public CommonResult saveHistoryRecord(@RequestBody HistoryRecordEntiry historyRecordEntiry){
        return CommonResult.ok(topicService.saveHistoryRecord(historyRecordEntiry));
    }

    /**
     * 查询历史记录
     * @return
     */
    @GetMapping("/getHistoryRecordList")
    public CommonResult getHistoryRecordList(Integer id){
        return CommonResult.ok(topicService.getHistoryRecordList(id));
    }
    /**
     * 搜索话题标签
     * @return
     */
    @GetMapping("/getHistoryRecordTopic")
    public CommonResult getHistoryRecordTopic(String title){
        return CommonResult.ok(topicService.getHistoryRecordTopic(title));
    }
    /**
     * 搜索日记
     * @return
     */
    @GetMapping("/getHistoryRecordDiary")
    public CommonResult getHistoryRecordDiary(String title){
        return CommonResult.ok(topicService.getHistoryRecordDiary(title));
    }
    /**
     * 搜索咨询
     * @return
     */
    @GetMapping("/getHistoryRecordInformation")
    public CommonResult getHistoryRecordInformation(String title){
        return CommonResult.ok(topicService.getHistoryRecordInformation(title));
    }
    /**
     * 搜索用户
     * @return
     */
    @GetMapping("/getHistoryRecordUser")
    public CommonResult getHistoryRecordUser(String title){
        return CommonResult.ok(topicService.getHistoryRecordUser(title));
    }
}